<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>个人信息 - 智能驾驶辅助系统</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css" rel="stylesheet">
</head>
<body class="bg-gray-100 min-h-screen">
    <div class="container mx-auto px-4 py-8">
        <header class="mb-8">
            <div class="flex justify-between items-center">
                <h1 class="text-2xl font-bold">智能驾驶辅助系统</h1>
                <div>
                    <a href="/" class="mr-4">系统首页</a>
                    <a href="/logout" class="text-red-600">退出登录</a>
                </div>
            </div>
        </header>

        <div class="bg-white rounded-lg shadow-lg p-8 max-w-md mx-auto">
            <h2 class="text-xl font-semibold mb-6">个人信息</h2>

            {% if request.query_params.success %}
            <div class="bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded mb-4">
                信息更新成功
            </div>
            {% endif %}

            {% if error %}
            <div class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded mb-4">
                {{ error }}
            </div>
            {% endif %}

            {% if user.success %}
            <form method="post" action="/update-profile">
                <div class="mb-4">
                    <label class="block text-gray-700 mb-2" for="username">
                        用户名
                    </label>
                    <input class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline bg-gray-100"
                           id="username" value="{{ user.username }}" disabled>
                </div>
                <div class="mb-4">
                    <label class="block text-gray-700 mb-2" for="email">
                        邮箱
                    </label>
                    <input class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"
                           id="email" name="email" type="email" value="{{ user.email }}" required>
                </div>
                <div class="mb-4">
                    <label class="block text-gray-700 mb-2" for="password">
                        密码 (不修改请留空)
                    </label>
                    <input class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"
                           id="password" name="password" type="password" placeholder="请输入新密码">
                </div>
                <div class="mb-4">
                    <label class="block text-gray-700 mb-2">
                        角色
                    </label>
                    <input class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline bg-gray-100"
                           value="{{ user.role }}" disabled>
                </div>
                <div class="mb-6">
                    <label class="block text-gray-700 mb-2">
                        注册时间
                    </label>
                    <input class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline bg-gray-100"
                           value="{{ user.created_at }}" disabled>
                </div>
                <button class="bg-primary hover:bg-primary/80 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline"
                        type="submit">
                    更新信息
                </button>
            </form>
            {% endif %}
        </div>
    </div>
</body>
</html>